/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28779
 * Date: 2023-03-30
 * Time: 8:29
 */

class Money{
    public double money;
}
class Student implements Cloneable{
    public int age ;
    public Money m = new Money();

    public Student(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();       //子类重写的clone 方法，只是调用了父类的clone方法
    }
}
public class Test {

    public static void main(String[] args) {
        Object student = new Student(10);
    }
    public static void main2(String[] args) throws CloneNotSupportedException {
        Student student = new Student(10);

        student.m.money = 19.9;

        Student student2 = (Student) student.clone();

        System.out.println(student.m.money);
        System.out.println(student2.m.money);

    }
    public static void main1(String[] args) throws CloneNotSupportedException {

        Student student = new Student(10);

        Student student2 = (Student) student.clone();

        System.out.println(student2);

        System.out.println(student);
    }
}
